<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>AP费用核销申请</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <!-- <link rel="shortcut icon" href="favicon.ico"> -->
      <!-- <link rel="shortcut icon" href="favicon.ico"> -->
   <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
        .borRed{border:1px solid red;padding: 4px;}
        .textBorder{border-color: red}
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">AP费用核销申请</h2>
    </div>
    <!-- 标题 -->
    <div >
    <form action="{:url('hexiaoscan')}" method="post" class="form-inline" id="f1">
    <input type="hidden" name="aid" value="{$aid}"/><input type="hidden" name="bu_state" id="bu_state" value="0"/>
      <table class="table table-bordered bud_hei" style="margin-top:0">
          <tr>
             <td>
              <button class="btn btn-warning" type="button" onclick="back()">点击返回列表</button>
            
             </td>
          </tr>
          <tr>
              <td>
              <a href="{:url('hexiao')}?aid={$aid}" class="btn btn-primary">可核销</a>
              <a href="{:url('hexiao')}?type=1&aid={$aid}" class="btn btn-primary">核销中</a>
              <a href="{:url('hexiao')}?type=2&aid={$aid}" class="btn btn-primary">不予核销</a>
              <a href="{:url('hexiao')}?type=3&aid={$aid}" class="btn btn-primary">未反馈</a>
              
              <a href="#" class="btn btn-primary">已锁定</a>
              </td>
          </tr>
          <tr>
              <td class="colorRed">温馨提示：一旦核销，原申请整单都不允许再做异动、取消、反馈。谢谢</td>
          </tr>
            <tr>
              <td class="font-bold">请选择下列要核销的记录后，点击"生成核销面单预览"按钮后即可核销。</td>
          </tr>
      </table>
      <table class="table table-striped table-bordered bud_hei text-center">
          <tr class="info">
            <th class="text-center" rowspan="2">序号</th>
            <th class="text-center" rowspan="2"><input type="checkbox" id="checkAll" checked class="form-control"></th>
            <th class="text-center" rowspan="2">申请人</th>
            <th class="text-center" rowspan="2">原申请文件</th>
            <th class="text-center" rowspan="2">明细编号</th>
            <th class="text-center" rowspan="2">渠道类型</th>
            <th class="text-center" rowspan="2">供应商名称</th>
            <th class="text-center" rowspan="2">分区</th>
            <th class="text-center" rowspan="2">省份</th>
            <th class="text-center" rowspan="2">城市</th>
            <th class="text-center" rowspan="2">经销商</th>
            <th class="text-center" rowspan="2">系统</th>
            <th class="text-center" rowspan="2">网点</th>
            <th class="text-center" rowspan="2">品牌</th>
            <th class="text-center" rowspan="2">品类</th>
            <th class="text-center" rowspan="2">系列</th>
            <th class="text-center" rowspan="2">三级费用科目</th>
            <th class="text-center" rowspan="2">预计销量</th>
            <th class="text-center" rowspan="2">实际销量</th>
            <th class="text-center" colspan="3">实际投入</th>
            <th class="text-center" colspan="8">本次核销</th>
            <th class="text-center" rowspan="2">余额不予核销</th>
            <th class="text-center" rowspan="2">活动开始日期</th>
            <th class="text-center" rowspan="2">支付方式</th>
            <th class="text-center" rowspan="2">备注</th>
            <th class="text-center" rowspan="2">操作</th>
          </tr>
          <tr class="info">
            <th class="text-center">实际投入金额</th>
            <th class="text-center">已核销金额</th>
            <th class="text-center">未核销金额</th>
            <th class="text-center">未税核销金额</th>
            <th class="text-center">
            有无发票<br><button type="button" class="btn-info" id="is_fap">批量设置</button>
            </th>
             <th class="text-center">
            发票号<span class="colorRed font-bold">?</span><br><button type="button" class=" btn-info" id="setFpNum">批量设置</button><span class="helpText">帮</span>
            </th>
             <th class="text-center">
            是否增值税<br>(可抵扣)<span class="colorRed font-bold">?</span>
            </th>
             <th class="text-center">
            税率<span class="colorRed font-bold">?</span>
            </th>
           <th class="text-center">税金</th> 
           <th class="text-center">含税核销金额</th> 
           <th class="text-center">实际投入金额</th> 
          </tr>
          {volist name="ade" id="vo1"}
          <tr>
          <td>{$i}</td>
		  <td><input type="checkbox" name="dids[]" value="{$vo1.id}" checked class="form-control cksdid"></td>
		  <td>{$vo1.cname}</td>
          <td><a href="javascript:;" onclick="xiangqing({$vo1.apid})">{$vo1.no}</a></td>
          <td>{$vo1.no}_{$vo1.detail_no}<a href="{:url('mingxijuece')}?did={$vo1.id}" title="决策依据" class="J_menuItem" ><span style="display: none;">决策依据</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td><td>{$vo1.channel}</td><td>{$vo1.gys_name}</td><td>{$vo1.fenqu}</td><td>{$vo1.sheng}</td><td>{$vo1.shi}</td><td>{$vo1.jxs}</td>
          <td>{$vo1.system}</td><td>{$vo1.net}</td><td>{$vo1.brand}</td><td>{$vo1.category}</td><td>{$vo1.series}</td><td>{$vo1.kemu3}</td><td class="num2i ObjectNum">{$vo1.zong_xiaoliang}</td><td class="num2i ObjectNum">{$vo1.fankuixiaoliang}</td><td class="num2i ObjectNum">{$vo1.zongjine}</td>
          <td class="num2i ObjectNum">{$vo1.hexiao}</td><td class="num2i ObjectNum">{$vo1.weihe}</td>
          <td><input type="text" class="form-control num2 heweishui" value="{$vo1.weihe}" name="weishui[]" style="min-width: 80px;width: 80px"></td>
          <td>
            <div class="form-group radioDiv">
            <label class="radio-inline">
              <input type="radio" name="isfa{$i}" class="fashi" value="1" >有
            </label>
             <label class="radio-inline">
                  <input type="radio" name="isfa{$i}" class="fafou" value="0">无
            </label>
            <input type="hidden" name="isfa[]" class="isfa" value=""/>
            </div>
          </td>
          <td><input type="text" name="fapiao[]" class="form-control fapiao" style="min-width: 80px;width: 80px;"></td>
          <td>
            <div class="form-group">
              <label class="radio-inline">
                <input type="radio" name="dikou{$i}" class="dikoushi" value="1" >是
              </label>
               <label class="radio-inline">
                    <input type="radio" name="dikou{$i}" class="dikoufou" value="0" checked>否
              </label>
              <input type="hidden" name="isdi[]" class="isdi" value="0"/>
            </div>
          </td>
            <td><input type="text" style="min-width: 60px;width: 60px;" class="form-control shuilv  num2" value="0" name="shuilv[]">%</td>
             <td><input type="text" style="min-width: 80px;width: 80px;" class="form-control shuijins  num2" value="0" ></td>
          <td><input type="text" class="form-control  num2" placeholder="" name="" value="{$vo1.weihe}" readonly style="min-width: 80px;width: 80px;"></td>
          <td><input type="text" class="form-control num2" placeholder="" value="{$vo1.zongjine}" readonly style="min-width: 80px;width: 80px;"></td>
          <td><input type="checkbox" name="yuebuhe[]" class="form-control yuebuhe" value="{$vo1.id}"></td>
           <td><input type="text" class="form-control layer-date" value="{$vo1.start_time}" readonly style="min-width: 100px;width: 100px;"></td>
          <td><select name="zfid[]"  class="form-control zfid">
            {volist name="fipay" id="vo" key='j'}
              {if condition="$vo.id eq $vo1.zfid"}
            <option value='{$vo.id}' selected>{$vo.title}</option>
              {else/}
          <option value='{$vo.id}'>{$vo.title}</option>
              {/if}
            {/volist}
          </select></td>
          <td><input type="text" name="beizhu[]" class="form-control"></td>
          <td> {if condition="$type eq 0"}<button type="button" class="btn-info" onclick="buyuhexiao({$vo1.id})">本条不予核销</button>{/if}</td>

          </tr>
         {/volist}
        
      </table>
      <table class="table-bordered table">
          <tr>
            <td rowspan="3" class="text-center" style="min-width: 120px;width: 120px">备注:</td>
            <td><textarea name="zongbeizhu" id="" class="form-control" style="width: 60%;overflow: auto;"></textarea><span style="vertical-align: bottom;">(500)</span></td>
          </tr>
      </table>
        <p class="colorRed">温馨提示：<br>
         1.如果有明细单不需要核销，请在该费用明细最后面点击："本条不予核销"按钮。<br>
         2.如核销一部分，所剩费用余额不需要核销,请勾选："余额不予核销"。
    </p>
    <br><br><br><br><br><br>
    {if condition="$type eq 0"}
         <div class="footer fixed_full text-center" style="height: auto;border:0;padding: 0;bottom: 18px;">
       <table class="table-bordered table text-center" style="margin:0;padding: 0;background: #f3f3f4">
          <tr>
            <td>未税金额合计：<span class="colorRed font-bold ObjectNum" id="wszonge">0</span>元；<button type="button" class="btn-primary btn" id="modify_notax">修改未税金额</button></td>
             <td>税金合计：<span class="colorRed font-bold ObjectNum" id="sjzonge">0</span>元；<button type="button" class="btn-primary btn" id="setFpInfo">设置发票信息</button></td>
             <td rowspan="2">
              <button type="button" class="btn-primary btn" id="create_verify_yl">生成核销申请预览</button>
             </td>
          </tr>
          <tr>
               <td>含税税金额合计：<span class="colorRed font-bold ObjectNum" id="hszong">0</span>元；<button type="button" class="btn-primary btn" id="modify_tax">修改含税金额</button></td>
               <td><input name="items1" type="checkbox" id="checkboxAll1">设置余额不予核销</td>
          </tr>
       </table>
    </div>
    {/if}
    </form>
    </div>
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
       <script src="__STATIC__/layout/js/common.js"></script>
      <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
      <script src="__STATIC__/layout/js/contabs_sub.js"></script>
     <script>
     function back(){
      location.href="{:url('index')}";
     }
     //详情页
     function xiangqing(aid){
     var index = layer.open({
                            type:2,
                            title:'常规促销申请',
                            area:['100%','100%'],
                            maxmin:true,
                            content:'{:url("apply_de")}?aid='+aid
                        })
}
//同步是否扣款
 function tongbukou(){
        $(".cksdid").each(function(){
                        if($(this).prop("checked")){
                          $(this).parent().nextAll().eq(28).children().prop("checked",true);
                        }else{
                           $(this).parent().nextAll().eq(28).children().prop("checked",false);
                        }
                    })
     }
    //设置整单余额不合
  $("#checkboxAll1").change(function(){
          var ck=$(this);
          if($(this).prop("checked")){
              swal({
            title: "提示",
            text: "您确定设置选定的余额不再核销吗？如确定则余额自动释放回预算池。请确认!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#FF3333",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: true
              },function(isConfirm){
                  if (isConfirm) {
                    $(".yuebuhe").attr("onclick","return false");
                    tongbukou();
                    
                  }else{
                    $(".yuebuhe").attr("onclick","return true");
                    ck.prop("checked",false);
                  }

                }

              )
            }else{
             $(".yuebuhe").attr("onclick","return true");
              $(".yuebuhe").prop("checked",false);
            }
          
     })
   //全选
     $("#checkAll").change(function(){
        if($(this).prop("checked")){
          $(".cksdid").prop("checked",true);
        }else{
          $(".cksdid").prop("checked",false);
        }
         if($("#checkboxAll1").prop("checked"))
            tongbukou();
         jisuanzongshu();
     })
    $(".cksdid").change(function(){
      var flag=1;
      $(".cksdid").each(function(){
        if(!$(this).prop("checked")){
          flag=0;
        }
      })
      if(flag==1){
         $("#checkAll").prop("checked",true);
      }else{
        $("#checkAll").prop("checked",false);
      }
      if($("#checkboxAll1").prop("checked"))
        tongbukou();
      jisuanzongshu();
    });
    jisuanzongshu();
  
     function jisuanzongshu(){
         var zongweishui=0;
          var zonghanshui=0;
          var zongshuijin=0;
        $(".cksdid").each(function(){
         
            if($(this).prop("checked")){
              zongweishui+=parseFloat(parseFloat($(this).parent().nextAll().eq(20).children().val()).toFixed(2));
               zonghanshui+=parseFloat(parseFloat($(this).parent().nextAll().eq(26).children().val()).toFixed(2));
               zongshuijin+=parseFloat(parseFloat($(this).parent().nextAll().eq(25).children().val()).toFixed(2));
            }
        })
        $("#sjzonge").html(zongshuijin.toFixed(2));
         $("#hszong").html(zonghanshui.toFixed(2));
        $("#wszonge").html(zongweishui.toFixed(2));

     }
    //不予核销按钮
   function buyuhexiao(did){
        $.post("{:url('dantiaomingxi')}",{did:did},function(re){
          var data=JSON.parse(re);
          var fankui=parseFloat(data["fankuijine"]).toFixed(2);
          var hexiao=parseFloat(data["hexiao"]).toFixed(2);
          var weihe=parseFloat(data["weihe"]).toFixed(2);
           swal({
            title: "提示",
            text: "实际投入金额为："+fankui+",已核销金额为："+hexiao+",未核销金额为："+weihe+",确定后不予核销金额为："+weihe+"请确认是否不予核销该金额再点击确定",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#FF3333",
            confirmButtonText: "是的不予核销",
            cancelButtonText: "取消",
            closeOnConfirm: true
        },
        function (isConfirm) {
            if (isConfirm) {
                $.post("{:url('nohexiao')}",{did:did,state:1},function(datas){
                    var res1=JSON.parse(datas);
                          if(res1["state"]==1){
                            swal({
                            title: "完成",
                            text: "操作已成功",
                            type: "success"
                            },function(){
                              
                              location.href=location.href;
                            });

                                  }else{
                                    swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                        }
                })
              }
          })
        })  
     }
      $(".heweishui").blur(function(){
         if(isNaN(parseFloat($(this).val()))){
              $(this).val("0.00");
            }else{
              $(this).val(parseFloat($(this).val()).toFixed(2));
            }
          var shuilv=$(this).parent().next().next().next().next().children().val();
          if(shuilv!=""){
            shuilv=parseFloat(shuilv);
            var price=parseFloat($(this).val());
            var shuijin=(price*shuilv/100).toFixed(2);
            var zonge=(price+parseFloat(shuijin)).toFixed(2);
            $(this).parent().next().next().next().next().next().children().val(shuijin);
             $(this).parent().next().next().next().next().next().next().children().val(zonge);
          }
          jisuanzongshu();
     })
     $(".shuijins").blur(function(){
         if(isNaN(parseFloat($(this).val()))){
              $(this).val("0.00");
            }else{
              $(this).val(parseFloat($(this).val()).toFixed(2));
            }
           var price=$(this).parent().prev().prev().prev().prev().prev().children().val();
            if(price!=""){
            price=parseFloat(price);
            var shuijin=parseFloat($(this).val());
            var shuilv=(shuijin/price*100).toFixed(2);
           
            var zonge=(price+parseFloat(shuijin)).toFixed(2);
            $(this).parent().prev().children().val(shuilv);
             $(this).parent().next().children().val(zonge);

          }
          jisuanzongshu();
     })
       $(".shuilv").blur(function(){
          if(isNaN(parseFloat($(this).val()))){
              $(this).val("0.00");
            }else{
              $(this).val(parseFloat($(this).val()).toFixed(2));
            }
         var price=$(this).parent().prev().prev().prev().prev().children().val();
          if(price!=""){
            price=parseFloat(price);
            var shuilv=parseFloat($(this).val());
            var shuijin=(price*shuilv/100).toFixed(2);
            var zonge=(price+parseFloat(shuijin)).toFixed(2);
            $(this).parent().next().children().val(shuijin);
             $(this).parent().next().next().children().val(zonge);
          }
          jisuanzongshu();
     })
     $(".fafou").change(function(){
        if($(this).prop("checked")){
          $(this).parent().parent().parent().next().children().val("").prop("readonly",true);
          $(this).parent().next().val(0);
        }
     })
      $(".fashi").change(function(){
        if($(this).prop("checked")){
          $(this).parent().parent().parent().next().children().val("").prop("readonly",false);
           $(this).parent().next().next().val(1);
        }
     })
       $(".dikoufou").change(function(){
        if($(this).prop("checked")){
          
          $(this).parent().next().val(0);
        }
     })
      $(".dikoushi").change(function(){
        if($(this).prop("checked")){
         
           $(this).parent().next().next().val(1);
        }
     })
        /*设置有无发票*/
        $("#is_fap").click(function(){
               var str = '<form  class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">批量设置有无发票</th></tr><tr><td style="min-width:120px;width:120px;" class="text-center">有无发票<span class="colorRed">*</span></td><td><label class="radio-inline"><input type="radio" name="inlineRadioOptionse" value="1" >有</label><label class="radio-inline"><input type="radio" name="inlineRadioOptionse" checked value="0">无</label></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" id="fapiaoqd" class="btn btn-success" value="确定"><input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></form>'
            layer.open({
              type: 1,
              title:"",
              skin: 'layui-layer-rim', //加上边框
              area: ['500px', '300px'], //宽高
              content: str
            });
              var cancelBack = document.getElementById('cancelBack')
              cancelBack.onclick = function(){
               layer.closeAll(); 
               }
                var fapiaoqd = document.getElementById('fapiaoqd')
                fapiaoqd.onclick = function(){
                    var vals=$("input[name='inlineRadioOptionse']:checked").val();
                   // alert(vals);
                    if(vals==0){
                      $(".fafou").prop("checked",true);
                      $(".fapiao").val("").prop("readonly",true);
                      $(".isfa").val(0);
                    }else{
                      $(".fashi").prop("checked",true);
                      $(".fapiao").prop("readonly",false);
                      $(".isfa").val(1);
                    }
                 layer.closeAll(); 
                 }
        })
          /*修改未税金额*/
        $("#modify_notax").click(function(){
             var zongweishui=0;
            var zongweihe=0;
            $(".cksdid").each(function(){
             
                if($(this).prop("checked")){
                  zongweishui+=parseFloat(parseFloat($(this).parent().nextAll().eq(20).children().val()).toFixed(2));
                  zongweihe+=parseFloat(parseFloat($(this).parent().nextAll().eq(19).html().replace(',','')).toFixed(2));
                }
            })
            zongweishui=parseFloat(zongweishui).toFixed(2);
            zongweihe=parseFloat(zongweihe).toFixed(2);
           var str = '<form method="get" class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">TI核销修改未税金额</th></tr><tr><td style="min-width:140px;width:140px;" class="text-center">原未税金额(元)</td><td><span class="ObjectNum">'+zongweishui+'</span></td></tr><tr><td style="min-width:140px;width:140px;" class="text-center">修改后未税金额(元)</td><td><input type="text" id="newweishui" class="form-control" style="min-width:100px;width:100px;"/><span style="display:none;color:red" id="tsweishui">金额不能为空</span></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="qdweishui" value="确认提交"><input type="button" class="btn btn-warning" value="关闭返回" id="cancelBack" style="margin-left:20px"></div></form>'
            layer.open({
              type: 1,
              title:"TI核销修改未税金额",
              skin: 'layui-layer-rim', //加上边框
              area: ['500px', '300px'], //宽高
              content: str
            });
              var cancelBack = document.getElementById('cancelBack')
              cancelBack.onclick = function(){
               layer.closeAll(); 
               }
               var newweishui=document.getElementById("newweishui")
               newweishui.onblur=function(){
                if(!isNaN(parseFloat(this.value))){
                  this.value=parseFloat(this.value).toFixed(2);
                }else{
                  this.value="";

                }
               }
                var qdweishui = document.getElementById('qdweishui')
              qdweishui.onclick = function(){

                if($("#newweishui").val()==""){
                  $("#tsweishui").show();

                }else{
                  $("#tsweishui").hide();
                   var xian=parseFloat($("#newweishui").val());
                   var bili=xian/zongweihe;
                  // alert(bili);
                    $(".cksdid").each(function(){
             
                        if($(this).prop("checked")){
                          var price=parseFloat($(this).parent().nextAll().eq(19).html().replace(',',''));
                          //alert(price);
                          var nejisuanpri=parseFloat(price*bili);
                          var newprice=nejisuanpri.toFixed(2);
                          $(this).parent().nextAll().eq(20).children().val(newprice);
                          var shuilv=parseFloat($(this).parent().nextAll().eq(24).children().val());
                          var sj=parseFloat(nejisuanpri*shuilv/100);
                          $(this).parent().nextAll().eq(25).children().val(sj.toFixed(2));
                          var zhs=sj+nejisuanpri;
                          $(this).parent().nextAll().eq(26).children().val(zhs.toFixed(2));
                        }
                    })
                      jisuanzongshu();
                      layer.closeAll(); 
                }
              // layer.closeAll(); 
               }
        })
         /*修改含税金额*/
        $("#modify_tax").click(function(){
           var hanshuisz=0;
           var zonghanshui=0;
        $(".cksdid").each(function(){
           
            if($(this).prop("checked")){
              
               var weihes=parseFloat($(this).parent().nextAll().eq(19).html().replace(',',''));
               var shuilv=parseFloat($(this).parent().nextAll().eq(24).children().val());
               hanshuisz+=parseFloat(weihes+weihes*shuilv/100);
                zonghanshui+=parseFloat($(this).parent().nextAll().eq(26).children().val());
            }

        })
         //alert(hanshuisz);
           var str = '<form method="get" class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">TI核销修改含税金额</th></tr><tr><td style="min-width:140px;width:140px;" class="text-center">原含税金额(元)</td><td><span class="ObjectNum">'+zonghanshui.toFixed(2)+'</span></td></tr><tr><td style="min-width:140px;width:140px;" class="text-center">修改后含税金额(元)</td><td><input type="text" id="newhanshui" class="form-control" style="min-width:100px;width:100px;"/><span style="display:none;color:red" id="tshanshui">金额不能为空</span></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="qdhanshui" value="确认提交"><input type="button" class="btn btn-warning" value="关闭返回" id="cancelBack" style="margin-left:20px"></div></form>'
            layer.open({
              type: 1,
              title:"TI核销修改含税金额",
              skin: 'layui-layer-rim', //加上边框
              area: ['500px', '300px'], //宽高
              content: str
            });
              var cancelBack = document.getElementById('cancelBack')
              cancelBack.onclick = function(){
               layer.closeAll(); 
               }
                   var newhanshui=document.getElementById("newhanshui")
               newhanshui.onblur=function(){
                if(!isNaN(parseFloat(this.value))){
                  this.value=parseFloat(this.value).toFixed(2);
                }else{
                  this.value="";

                }
               }
               var qdhanshui= document.getElementById('qdhanshui')
              qdhanshui.onclick = function(){
                  if($("#newhanshui").val()==""){
                  $("#tshanshui").show();

                  }else{
                    $("#tshanshui").hide();
                     var xian=parseFloat($("#newhanshui").val());
                      var bili=xian/hanshuisz;
                       $(".cksdid").each(function(){
             
                        if($(this).prop("checked")){
                           var weihes=parseFloat($(this).parent().nextAll().eq(19).html().replace(',',''));
                            var shuilv=parseFloat($(this).parent().nextAll().eq(24).children().val());
                            var price=parseFloat(weihes+weihes*shuilv/100);
                            var nejisuanpri=parseFloat(price*bili);
                            $(this).parent().nextAll().eq(26).children().val(nejisuanpri.toFixed(2));
                            var weishuisa=parseFloat(nejisuanpri/(1+shuilv/100));
                            var sj=parseFloat(nejisuanpri-weishuisa);
                             $(this).parent().nextAll().eq(25).children().val(sj.toFixed(2));
                              $(this).parent().nextAll().eq(20).children().val(weishuisa.toFixed(2));
                        }
                    })
                      jisuanzongshu();
                      layer.closeAll(); 
                  }
               }
        })

         /*批量设置发票号*/
        $("#setFpNum").click(function(){
            var str = '<form  class="form-inline" style="margin:10px"><table class="table-bordered table"><tr><th class="info text-center" colspan="2">批量设置发票号</th></tr><tr><td style="min-width:120px;width:120px;" class="text-center">发票号<span class="colorRed">*</span>：</td><td><input type="text" id="tongyifph" class="form-control"/></td></tr></table> <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0"><input type="button" class="btn btn-success" id="fphqd" value="确定"><input type="button" class="btn btn-warning" value="返回" id="cancelBack" style="margin-left:20px"></div></form>'
            layer.open({
              type: 1,
              title:"",
              skin: 'layui-layer-rim', //加上边框
              area: ['500px', '300px'], //宽高
              content: str
            });
              var cancelBack = document.getElementById('cancelBack')
              cancelBack.onclick = function(){
               layer.closeAll(); 
               }
                var fphqd = document.getElementById('fphqd')
             fphqd.onclick = function(){
              var neirong=$("#tongyifph").val();
                $(".fapiao").each(function(){
                    if(!$(this).prop("readonly")){
                      $(this).val(neirong);
                    }
                })
               layer.closeAll(); 
               }
        })
           /*设置发票信息*/
        $("#setFpInfo").click(function(){
            layer.open({
              type: 2,
              skin: 'layui-layer-rim', //加上边框
              area: ['660px', '500px'], //宽高
              content: '{:url("setfapiao")}'
            });
        })

          /*生成核销申请预览*/
      $("#create_verify_yl").click(function(){
        var flag=0;
        var errortag=0;
          $(".cksdid").each(function(){
            if($(this).prop("checked")){
              var isse=$(this).parent().nextAll().eq(21).children().find(".fashi").prop("checked");
              var isno=$(this).parent().nextAll().eq(21).children().find(".fafou").prop("checked");
              if(!(isse||isno)){
                
                $(this).parent().nextAll().eq(21).find(".radioDiv").addClass("borRed");
                errortag=1;
              }else{
               
                $(this).parent().nextAll().eq(21).find(".radioDiv").removeClass("borRed");
              }
              flag=1;
             
            }
          })
          if(flag==0){
            swal("", "至少选中一条明细！","error"); 
          }else{
            if(errortag==0){
              $(".cksdid").each(function(){
                 if(!$(this).prop("checked")){

                    $(this).parent().parent().remove();
                    
                 }
              })
              document.getElementById("f1").submit();
            }else{
               swal("", "请将红色框内的数据填写完整！","error"); 
            }
          }
         
      });
   		$(function(){
   			  $(".num2i").each(function(){
		        $(this).html(parseFloat($(this).html()).toFixed(2));
		     })
   			    $(".num2").each(function(){
        $(this).val(parseFloat($(this).val()).toFixed(2));
     })
         var $ObjectNum =$(".ObjectNum");
               toNum($ObjectNum);

   		})
    </script>
</body>

</html>